# -*- coding: utf-8 -*-
#
# @Author: CPS
# @email: 373704015@qq.com
# @Date:
# @Last Modified by: CPS
# @Last Modified time: 2021-10-08 17:08:20.719937
# @file_path "Z:\CPS\MyProject\gis\gis-driven-data-table"
# @Filename "ToolValidator.py"
# @Description: 参数验证
#

if ( __name__ == "__main__"):
  pass


import arcpy
class ToolValidator(object):
  """Class for validating a tool's parameter values and controlling
  the behavior of the tool's dialog."""

  def __init__(self):
    """Setup arcpy and the list of tool parameters."""
    self.params = arcpy.GetParameterInfo()

  def initializeParameters(self):
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""

    # 面的字段依赖面元素的选择
    self.params[2].parameterDependencies = [0]
    self.params[3].parameterDependencies = [0]

    self.params[6].parameterDependencies = [4]
    self.params[7].parameterDependencies = [4]

    return

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parameter
    has been changed."""

    if self.params[0].value:
      self.params[1] = self.params[0]
      self.params[3] = self.params[0]


    if self.params[4].value:
      self.params[6] = self.params[4]
      self.params[7] = self.params[4]

    return

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""
    return

